using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Demo.SharePoint.Utilities;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;

namespace Demo.SharePoint.Features.DemoWebParts
{
    /// <summary>
    /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
    /// </summary>
    /// <remarks>
    /// The GUID attached to this class may be used during packaging and should not be modified.
    /// </remarks>
    [Guid("22fe873a-81e5-4dc8-b026-28ad018e8fd5")]
    public class DemoWebPartsEventReceiver : SPFeatureReceiver
    {
        #region Overrides of SPFeatureReceiver

        /// <summary>
        /// Occurs after a Feature is activated.
        /// </summary>
        /// <param name="properties">An <see cref="T:Microsoft.SharePoint.SPFeatureReceiverProperties"></see> object that represents the properties of the event.</param>
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = (SPSite)properties.Feature.Parent;
#if !DEBUG
            GoogleMaps googleMaps = new GoogleMaps(site, string.Empty);
#endif
#if DEBUG
            GoogleMaps googleMaps = new GoogleMaps(site, "ABQIAAAA2Bmtvoi5PDcE3iLwMNJk2RQnvhZTaMCfkJ4zXVkjoKntBJfjVRS8gLW0vb9sjiR6J_6kLFFfiVbn5A");
#endif
        }

        /// <summary>
        /// Occurs when a Feature is deactivated.
        /// </summary>
        /// <param name="properties">An <see cref="T:Microsoft.SharePoint.SPFeatureReceiverProperties"></see> object that represents the properties of the event.</param>
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite site = (SPSite)properties.Feature.Parent;
            SPWeb topWeb = site.RootWeb;
            topWeb.Properties.Remove(GoogleMaps.Pname);
        }

        #endregion
    }
}
